<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('开课计划列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>开课名称：</p>
                                <input type="text" name="kaikeName"/>
                            </li>
                            <li>
                                <p>学期：</p>
<!--                                <input type="text" name="courseName"/>-->
                                <!--<select name="stuTerm" class="form-control m-b" th:with="type=${@dict.getType('sys_period')}" style="height:34px;">
                                    <option value="0">全部学期</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>-->
                                <select th:with="terms=${@term.selectTbTermList()}" name="stuTerm" class="form-control m-b" style="height:34px;">
                                    <option value="">全部学期</option>
                                    <option th:each="term : ${terms}" th:value="${term.id}" th:text="${term.schoolYear +'学年  第'+term.term+'学期'+' (' + #dates.format(term.startTime, 'yyyy-MM-dd') + '&#45;&#45;' + #dates.format(term.endTime, 'yyyy-MM-dd')+') '}"></option>
                                </select>
                            </li>
                            <li>
                                <p>开课教师：</p>
                                <input type="text" name="courseTeacher"/>
                            </li>
                            <!--<li class="select-time">
                                <p>上课时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCourseTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCourseTime]"/>
                            </li>-->
                            <li>
                                <p>开课：</p>
<!--                                <input type="text" name="courseAddress"/>-->
                                <select name="kaikeStatus">
                                    <option value="">全部课程</option>
                                    <option value="0">未开课</option>
                                    <option value="1">已开课</option>
                                </select>
                            </li>
                            <!--<li>
                                <p>发布状态：</p>
                                <input type="text" name="fabuState"/>
                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="website:kaikeplan:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="website:kaikeplan:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="website:kaikeplan:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()">
                    <i class="fa fa-upload"></i> 导入
                </a>

                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="website:kaikeplan:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('website:kaikeplan:edit')}]];
        var removeFlag = [[${@permission.hasPermi('website:kaikeplan:remove')}]];
        var fabuFlag = [[${@permission.hasPermi('system:plan:fabu')}]];
        var prefix = ctx + "website/kaikeplan";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/import",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "开课计划",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '序号',
                    visible: true,
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field : 'kaikeName', 
                    title : '开课名称'
                },
                {
                    field : 'courseName', 
                    title : '课程名称'
                },
                {
                    field : 'courseTeacher', 
                    title : '开课教师'
                },
                {
                    field: 'courseWeekTime',
                    title: '上课周次',
                    formatter: function (value, row, index) {
                        return value = "第" + row.classlowweek + "周至" + row.classmaxweek + "周";
                    }

                },
                {
                    field : 'courseTime', 
                    title : '上课时间',
                    formatter: function (value, row, index) {
                        if(row.courseWeektime==1){
                            return value="周一"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }else if(row.courseWeektime==2){
                            return value="周二"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }else if(row.courseWeektime==3){
                            return value="周三"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }else if(row.courseWeektime==4){
                            return value="周四"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }else if(row.courseWeektime==5){
                            return value="周五"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }else if(row.courseWeektime==6){
                            return value="周六"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }else if(row.courseWeektime==7){
                            return value="周日"+row.firstCouretime+"至"+row.lastCouretime+"节";
                        }
                    }
                },
                {
                    field : 'courseAddress', 
                    title : '上课地点'
                },
                {
                    field : 'fabuState',
                    title : '发布状态',
                    formatter: function (value, row, index) {
                        if(value=="0"){
                            return value="<a class='btn btn-warning btn-xs'  href=\"javascript:void(0)\"><i class=\"fa\"></i>未发布</a>";
                        }else if(value=="1"){
                            return value="<a class='btn btn-secondary btn-xs'  href=\"javascript:void(0)\"><i class=\"fa\"></i>已发布</a>";
                        }
                    }
                },
                {
                    field : 'kaikeState',
                    title : '开课状态',
                    formatter: function (value, row, index) {
                        if(value=="0"){
                            return value="<a class='btn btn-warning btn-xs'  href=\"javascript:void(0)\"><i class=\"fa\"></i>未开课</a>";
                        }else if(value=="1"){
                            return value="<a class='btn btn-primary btn-xs'  href=\"javascript:void(0)\"><i class=\"fa\"></i>已开课</a>";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + fabuFlag + '" onclick="fabu(\'' + row.id + '\')"><i class="fa fa-edit"></i>发布</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + fabuFlag + '" href="javascript:void(0)" onclick="fabu(\'' + row.id + '\')"><i class="fa fa-edit"></i>发布</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function fabu(id){
                $.modal.confirm("确认要发布吗?", function() {
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        url: prefix + "/fabu",
                        data: {
                            id:id,
                        },
                        cache: false,
                        async: true,
                        success: function (data) {
                            $.modal.alertSuccess("发布成功");
                            $.table.refresh();
                        }
                    });
                });
        }
    </script>
     <!-- 导入区域 -->
     <script id="importTpl" type="text/template">
         <form enctype="multipart/form-data" class="mt20 mb10">
             <div class="col-xs-offset-1">
                 <input type="file" id="file" name="file"/>
                 <div class="mt10 pt5">
                     <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                     &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
                 </div>
                 <font color="red" class="pull-left mt10">
                     提示：仅允许导入“xls”或“xlsx”格式文件！
                 </font>
             </div>
         </form>
     </script>

</body>
</html>